<div class="page-group">
    <div class="page" data-page="book_kind">
    <header class="bar bar-nav">
        <a onclick="goback()" class="icon" style="width: 40%">
            <img src="__PUBLIC__/img/iconfont_back@2x.png" class="back_img">
        </a>
    </header>
    <nav class="bar bar-tab old_bar">
          <a class="tab-item external" onclick="collect()">
              <if condition="$d['is_fav'] eq 0">
                  <img id="collectOrnot" src="__PUBLIC__/img/collecte@2x.png" style="height: 20px;width: 55px">
                <!--  <img src="img/collected@2x.png" style="height: 20px;width: 55px"> -->
              <else/>
                  <img id="collectOrnot" src="__PUBLIC__/img/collected@2x.png" style="height: 20px;width: 55px">
              </if>
          </a>
        <if condition="$d['is_apply'] eq 0">
            <a class="tab-item external" onclick="document.getElementById('myform').submit();">
                <input id="iwantenroll" class="btn_radius" type="button" value="报名"  style="background: #EC623E;width: 180px;padding:8px;border:none;color:#FFF">
            </a>
        <else/>
            <a class="tab-item external">
                <if condition="$d['refund_status'] eq null"><!--如果没有退款-->
                    <input id="refund" onclick="refund()" class="btn_radius" type="button" value="申请退款{$d.refund_id}"  style="background: #ddd;width: 80px;padding:8px;border:none;color:#FFF">
                    <input id="iwantenroll" class="btn_radius" type="button" value="已报名"  style="background: #EC623E;width: 100px;padding:8px;border:none;color:#FFF">
                    <else/><!--如果有退款,还未成功-->
                    <switch name="d.refund_status" >
                        <case value="0">
                            申请退款中
                            <input id="iwantenroll" class="btn_radius" type="button" value="已报名"  style="background: #EC623E;width: 100px;padding:8px;border:none;color:#FFF">
                        </case>
                        <case value="1">
                            退款成功
                        </case>
                        <case value="2">
                            退款失败
                            <input id="iwantenroll" class="btn_radius" type="button" value="已报名"  style="background: #EC623E;width: 100px;padding:8px;border:none;color:#FFF">
                        </case>
                        <case value="3">
                            拒绝退款
                            <input id="iwantenroll" class="btn_radius" type="button" value="已报名"  style="background: #EC623E;width: 100px;padding:8px;border:none;color:#FFF">
                        </case>
                        <default />
                    </switch>

                </if>

            </a>
        </if>
          <!--<a class="tab-item external" href="#">-->
              <!--<img src="__PUBLIC__/img/share@2x.png" style="height: 17px;width: 50px">-->
          <!--</a>-->

        <form id="myform" action="{:U("User/activity_order_confirm")}" method="get">
            <input type="hidden"  name="id" value="{$d['activity_id']}" />
        </form>
      </nav>
      <div class="content doublecontent"  style="bottom:0;">
          <div class="act_new_top">
              <div class="act_top_name rec_div_book_name">{$d.title}</div>
              <div><img src="{$d.a_logo}" style="width: 100%;height: 130px;padding: 10px"></div>
              <div class="death_time"><font color="#CCCCCC">报名时间：</font>{:date("Y-m-d",strtotime($d['apply_start']))}至{:date("Y-m-d",strtotime($d['apply_end']))}</div>
              <div class="report_num color_book_kind_titile">{$d.apply_num}人</div>
              <div class="report_num color_book_kind_titile">可使用&nbsp;&nbsp;{$d.num_deduct}&nbsp;&nbsp;个{$Think.config.act_freenum_name}</div>
          </div>
          <div class="activity_report">
              <div class="book_detail_link book_intro_act">
                  <img src="__PUBLIC__/img/introduce@2x.png" style="width: 20%;height: 30%">
              </div>
              <div class="book_intro">
                  {$d.content}
              </div>
              <div class="activity_time">
                  <p>大赛时间</p>
                  <p>报名时间：{:date("m月d日",strtotime($d['apply_start']))}-{:date("m月d日",strtotime($d['apply_end']))}</p>
                  <p>报名费：{$d.price_apply}元</p>
                  <p>活动主办方：{$d.sponsor}</p>
                  <p>联系方式：{$d.contact}</p>
              </div>
          </div>

      </div>
  </div>
</div>
<script>
    var a={$d.is_fav};
    function  collect(){
        if(a%2==1){
            $.ajax({
                type: "GET",
                url: "{:U('Activity/cancel_fav')}",
                data: {id:{$d.activity_id}},
                dataType: "json",
                success: function(data){
                    if(data==1){
                        $.alert("已取消收藏");
                        $("#collectOrnot").attr("src","__PUBLIC__/img/collecte@2x.png");
                        a=0;
                    }
                }
            });
        }else{
            $.ajax({
                type: "GET",
                url: "{:U('Activity/join_fav')}",
                data: {id:{$d.activity_id}},
                dataType: "json",
                success: function(data){
                    if(data==1){
                        $.alert("已加入收藏");
                        $("#collectOrnot").attr("src","__PUBLIC__/img/collected@2x.png");
                        a++;
                    }
                }
            });
        }
    }

    function refund() {
        $.ajax({
            type: "GET",
            url: "{:U('Activity/refund')}",
            data: {id:{$d.activity_id}},
            dataType: "json",
            success: function(data){
                $.alert(data.data,function(){
                    window.location.reload();
                });
            }
        });
    }

</script>